package cpr;

import static org.junit.Assert.assertEquals;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.testing.RobotTestBed;
/**
 * 
 * @author Christopher Ramelb
 * This is adapted from Professor Philip Johnson and his TestDaCruzerVersusSittingDuck.java.
 * Please credit Philip Johnson and his pmj.DaCruzer Robot
 * for help and providing a template of the following code.  
 */
public class TestAgainstCrazy extends RobotTestBed {
  /**
   * Specifies that SittingDuck and BobBot will be used in this match.
   * @return the list of robots used in the match
   */
  @Override
  public String getRobotNames() {
    return "sample.Crazy,cpr.BobBot";
  }
  /**
   * Override default number of rounds from 1 to 10.
   * @return the number of rounds
   */
  @Override
  public int getNumRounds() {
    return 10;
  }
  
  /**
   * This code was taken and adapted from Professor P. Johnson's
   * pmj.TestBadCruzerVersusSittingDuck
   * @param e is info about currect state of battle
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent e) {
    //gets results and organize them by index in an array
    BattleResults[] battleResults = e.getIndexedResults();
    BattleResults bobBotResults = battleResults[1];
    String robotName = bobBotResults.getTeamLeaderName();
    assertEquals("Check that results[1] is BobBot", robotName, "cpr.BobBot*");
    assertEquals("Check if BobBot is winner", bobBotResults.getFirsts(), getNumRounds());
  }
  
}
